package com.dmall.netty.chapter02.section22.pool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class TimeServerHandlerExecutorPool {

	private ExecutorService executorService;

	public TimeServerHandlerExecutorPool(int maximumPoolSize, int queueSize) {
		executorService = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), maximumPoolSize, 120L,
				TimeUnit.SECONDS, new ArrayBlockingQueue<>(queueSize));
	}
	
	public void execute(Runnable task) {
		executorService.submit(task);
	}
}
